class Solution {
    public int[] exchange(int[] nums) {
        int left=0;
        int right=nums.length-1;
        while(left<right){
            while(left<right&&nums[left]%2==1){
                left++;
            }
            while(left<right&&nums[right]%2==0){
                right--;
            }
            int val=nums[left];
            nums[left]=nums[right];
            nums[right]=val;
        }
        return nums;
    }
    //剑指 Offer 18. 删除链表的节点
    class  ListNode{
        int val;
        ListNode next;

        public ListNode(int val) {
            this.val = val;
        }
    }
    public ListNode deleteNode(ListNode head, int val) {
        //判断头结点是否为空
        if(head==null){
            return null;
        }
        //判断该节点是否时头节点,是的话，进行头删
        if(head.val==val){
            head=head.next;
            return head;
        }
        //不是头节点，遍历列表进行删除
        ListNode cur=head;
        while(cur.next!=null){
            if(cur.next.val==val){
                cur.next=cur.next.next;
                break;
            }
            cur=cur.next;
        }
        return head;
    }
    //剪绳子
    public int cuttingRope(int n) {
   if(n<4){
       return n-1;
   }
   int [] arr=new int [n+1];
   arr[1]=1;
   arr[2]=2;
   arr[3]=3;
   arr[4]=4;
   for(int i=5;i<=n;i++){
       for(int j=1;j<i;j++){
           arr[i]=Math.max(arr[i],j*arr[i-j]);
       }
   }
   return arr[n];
    }
}